import { createRouter, createWebHistory } from 'vue-router'

import type { App } from 'vue'
import type { RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    component: () => import('@/views/home/index.vue'),
  },
  {
    path: '/ce/:id',
    component: () => import('@/views/home/ce.vue'),
    props: (route) => ({ id: route.params.id })

  },
  {
    path: '/dot/:id',
    component: () => import('@/views/home/dot.vue'),
    props: (route) => ({ id: route.params.id })

  },{
    path: '/line',
    component: () => import('@/views/home/line.vue')
  },
  {
    path: '/surface/:id',
    component: () => import('@/views/home/surface.vue'),
    props: (route) => ({ id: route.params.id })

  },
  {
    path: '/book/:id',
    component: () => import('@/views/home/book.vue'),
    props: (route) => ({ id: route.params.id })
  },
  {
    path: '/audio',
    component: () => import('@/views/home/audio.vue')
  },
  {
    path: '/tool/pinia',
    component: () => import('@/views/tool/pinia.vue')
  },
  {
    path: '/tool/scss',
    component: () => import('@/views/tool/scss.vue')
  },
  {
    path: '/tool/svg',
    component: () => import('@/views/tool/svg.vue')
  },
  {
    path: '/tool/rem',
    component: () => import('@/views/tool/rem.vue')
  },
  {
    path: '/tool/imageCompression',
    component: () => import('@/views/tool/imageCompression.vue')
  }
]

const router = createRouter({
  routes,
  history: createWebHistory()
})

// eslint-disable-next-line import/prefer-default-export
const useRouter = (app: App) => {
  app.use(router)
}
export default useRouter
